package com.java.base.exercise.designmode.guanchazhe;

import com.mysql.cj.jdbc.Clob;

/**
 * @Author RenPu
 * @Date 2021/12/16 11:51
 * @Version 1.0
 * @Description: 初始化事件管理状态
 **/
public abstract class LotteryServiceV2 {

    private EventManager eventManager;


    private Clob ko;

    private Integer ll;

    /**
     * 初始化事件管理,事件类型以及事件订阅的模式
     */
    public LotteryServiceV2() {
       eventManager=new EventManager(EventManager.EventType.Message, EventManager.EventType.MQ);
       eventManager.subscribe(EventManager.EventType.Message,new DuanMessageSend());
        eventManager.subscribe(EventManager.EventType.MQ,new MQmessageSend());
    }


    /**
     *
     * @param uId
     * @return
     */
    public LotteryResult draw(String uId) {

        LotteryResult lotteryResult = doDraw(uId);

        eventManager.notif(EventManager.EventType.Message,lotteryResult);
        eventManager.notif(EventManager.EventType.MQ,lotteryResult);

        return lotteryResult;



    }



    protected abstract LotteryResult doDraw(String uId);

}
